import pandas as pd
import os

job_list = ["算法", "软件", "前端", "人工智能", "数据", "Android", "Java", "安卓", "运维", "图像"]
address_list = ["成都", "西安", "北京", "西安", "杭州", "上海", "南京", "武汉", "深圳", "广州"]

for job in job_list:
    for address in address_list:
        print("正在分离\"{}\"的{}数据".format(job, address))
        input_file = "./data4_3_classify_job/{}.xlsx".format(job)
        output_file = "./data4_4_classify_address/{}{}.xlsx".format(job, address)
        directory = 'data4_4_classify_address'
        if not os.path.exists(directory):
            os.makedirs(directory)
        data1 = pd.read_excel(input_file)
        data1 = data1.drop("Unnamed: 0", axis=1)
        data1 = data1.values

        job_name = []
        company_name = []
        salary = []
        address1 = []
        education_requirements = []

        for item in data1:
            if address in item[3]:
                job_name.append(item[0])
                company_name.append(item[1])
                salary.append(item[2])
                address1.append(item[3])
                education_requirements.append(item[4])

        data2 = {
            "job_name": job_name,
            "company_name": company_name,
            "salary": salary,
            "address": address1,
            "education_requirements": education_requirements
        }
        data2 = pd.DataFrame(data2)
        data2.to_excel(output_file)